<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>审核页面</title>
    <jsp:include page="../../head.jsp"/>
</head>
<script type="text/javascript">
    var formSetting = {
        title: "注册审核数据",
        module: 'save',
        numCount: '3',
        columns: [{
            index: "REG_COMPANY_ID",
            name: "reg_company_id",
            label: "REG_COMPANY_ID",
            hidden: true
        }, {
            index: "COM_NAME",
            name: "com_name",
            readonly: true,
            label: "公司名称"
        }, {
            index: "COM_CODE",
            name: "com_code",
            readonly: true,
            label: "统一社会信用代码"
        }, {
            index: "COM_CUSTOMS_CODE",
            name: "com_customs_code",
            readonly: true,
            label: "海关企业注册代码"
        }, {
            index: "COM_LINK_PERSON",
            name: "com_link_person",
            readonly: true,
            label: "公司联系人"
        }, {
            index: "COM_LINK_PHONE",
            name: "com_link_phone",
            readonly: true,
            label: "联系人电话"
        }, {
            index: "COM_EMAIL",
            name: "com_email",
            readonly: true,
            label: "公司邮箱"
        }, {
            index: "CUSTOMS_BROKER",
            name: "customs_broker",
            readonly: true,
            label: "推荐报关行"
        }, {
            index: "CUSTOMS_BROKER_ID",
            name: "customs_broker_id",
            readonly: true,
            label: "推荐报关行id",
            hidden: true
        }, {
            index: "COM_ADDRESS",
            name: "com_address",
            readonly: true,
            label: "公司地址"
        }, {
            index: "APPROVE_STATUS",
            name: "approve_status",
            type: "dropdown",
            data: [["通过", "0"], ["不通过", "1"]],
            label: "报关行审核",
            readyonly: true
        }, {
            index: "APPROVE_TIME",
            name: "approve_time",
            formatter: 'date',
            formatoptions: {
                srcformat: 'Y-m-d H:i:s',
                newformat: 'Y-m-d H:i:s'
            },
            readonly: true,
            label: "报关行审核时间"
        }, {
            index: "PLATFORM_APPROVE_STATUS",
            name: "platform_approve_status",
            type: "dropdown",
            data: [["通过", "0"], ["不通过", "1"]],
            label: "平台审核"
        }, {
            index: "APPROVE_RESULT",
            name: "platform_approve_time",
            formatter: 'date',
            formatoptions: {
                srcformat: 'Y-m-d H:i:s',
                newformat: 'Y-m-d H:i:s'
            },
            readonly: true,
            label: "平台审核时间"
        }, {
            index: "APPROVE_RESULT",
            name: "approve_result",
            type: "textarea",
            colspan: "3",
            label: "报关行审核反馈"
        }, {
            index: "PLATFORM_APPROVE_RESULT",
            name: "platform_approve_result",
            type: "textarea",
            colspan: "3",
            label: "平台审核反馈"
        }, {
            index: "SO_FILE_ID",
            name: "so_file_id",
            readonly: true,
            label: "so_file_id",
            hidden: true
        }, {
            index: "COM_TYPE",
            name: "com_type",
            readonly: true,
            label: "公司类型",
            hidden: true
        }, {
            index: "SERVICE_PORT",
            name: "service_port",
            readonly: true,
            label: "服务口岸",
            hidden: true
        }, {
            index: "SERVICE_PORT_CODE",
            name: "service_port_code",
            readonly: true,
            label: "服务口岸代码",
            hidden: true
        }],
        form: {
            'url': 'approve-saveOrUpdate',
            'data': function () {
                var id = "${reg_company_id}";
                if (id) {
                    var dataValue = "";
                    $
                            .ajax({
                                      url: "approve-find?reg_company_id="
                                           + id,
                                      async: false,
                                      cache: false,
                                      success: function (data) {
                                          dataValue = data;
                                      }
                                  });
                    if (dataValue.approve_time) {
                        dataValue.approve_time =
                                new Date(dataValue.approve_time).toJSON().substring(0, 19).replace(
                                        'T', ' ');
                    }
                    if (dataValue.platform_approve_time) {
                        dataValue.platform_approve_time =
                            new Date(dataValue.platform_approve_time).toJSON().substring(0, 19).replace(
                                'T', ' ');
                    }

                    return dataValue;
                } else {
                    return null;
                }
            },
            'afterAjaxSuccess': function (responseText, statusText, xhr, $form) {
                /*做了审核以后有让去直接去更新左侧的数据 不去后台取  直接减一*/
                try{window.top.regCountReminder.Count__=(window.top.regCountReminder.Count__-1);window.top.regCountReminder.load();}catch(exe){}
                var id = "${reg_company_id}";
                location.href = "approve-platformApprove?reg_company_id=" + id;
            }
        },
        buttons: {
            custom: [
                {
                    id: "passBtn",
                    value: "通过审核",
                    click: function () {
                        if ($("input[name='customs_broker']").val() != "" && $(
                                        "input[name='customs_broker_id']").val()
                                                                             != "") {
                            if ($("input[name='control_registeredCompany_approve_status_dropdown']").val()
                                == "") {
                                jw.alert("推荐报关行尚未审核，应该由推荐报关行先审核!");
                            } else {
                                if ($("input[name='control_registeredCompany_approve_status_dropdown']").val()
                                    != "不通过") {
                                    $("input[name='platform_approve_status']").val(
                                            "0");
                                    $("input[name='control_registeredCompany_platform_approve_status_dropdown']").val(
                                            "通过");
                                    $("#saveButton").click();
                                    $("#passBtn").attr("disabled", true);

                                } else {
                                    jw.alert("该注册公司推荐报关行审核不通过!");
                                }
                            }
                        } else {
                            if ($("input[name='control_registeredCompany_approve_status_dropdown']").val()
                                != "不通过") {
                                $("input[name='platform_approve_status']").val(
                                        "0");
                                $("input[name='control_registeredCompany_platform_approve_status_dropdown']").val(
                                        "通过");
                                $("#saveButton").click();
                                $("#passBtn").attr("disabled", true);

                            } else {
                                jw.alert("该注册公司推荐报关行审核不通过!");
                            }
                        }
                    }
                },
                {
                    id: "rejectBtn",
                    value: "审核不通过",
                    click: function () {
                        if ($("input[name='customs_broker']").val() != "" && $(
                                        "input[name='customs_broker_id']").val()
                                                                             != "") {
                            if ($("input[name='control_registeredCompany_approve_status_dropdown']").val()
                                == "") {
                                jw.alert("推荐报关行尚未审核，应该由推荐报关行先审核!");
                            } else {
                                if ($("input[name='control_registeredCompany_approve_status_dropdown']").val()
                                    != "不通过") {
                                    if ($("textarea[name='platform_approve_result']").val()
                                        == "") {
                                        jw.alert("请填写平台审核反馈!");
                                        return;
                                    }
                                    $("input[name='platform_approve_status']").val(
                                            "1");
                                    $("input[name='control_registeredCompany_platform_approve_status_dropdown']").val(
                                            "不通过");
                                    $("#saveButton").click();
                                    $("#rejectBtn").attr("disabled", true);
                                } else {
                                    jw.alert("该注册公司推荐报关行审核不通过!");
                                }
                            }
                        } else {
                            if ($("input[name='control_registeredCompany_approve_status_dropdown']").val()
                                != "不通过") {
                                if ($("textarea[name='platform_approve_result']").val()
                                    == "") {
                                    jw.alert("请填写平台审核反馈!");
                                    return;
                                }
                                $("input[name='platform_approve_status']").val(
                                        "1");
                                $("input[name='control_registeredCompany_platform_approve_status_dropdown']").val(
                                        "不通过");
                                $("#saveButton").click();
                                $("#rejectBtn").attr("disabled", true);
                            } else {
                                jw.alert("该注册公司推荐报关行审核不通过!");
                            }
                        }
                    }
                },
                /*{
                 id: "downloadbtn",
                 value: "下载附件",
                 click: function () {
                 var attachmentId = $("#formtable").mrdForm(
                 "formVal", "so_file_id");
                 if (attachmentId == "") {
                 jw.alert("无附件下载");
                 } else {
                 window.location.href = "/gtimp/business/download?attachment.id="
                 + $("#formtable").mrdForm("formVal",
                 "so_file_id");
                 }
                 }
                 }, */{
                    id: "cancelbtn",
                    value: "返回",
                    click: function () {
                        //$('#center', window.parent.document).attr("src","province-main");
                        history.go(-1);
                    }
                }]
        },
    };
    $(document)
            .ready(
                    function () {
                        $("#formtable").mrdForm(formSetting);
                        $("#saveButton").hide();
                        $(
                                "input[name='control_registeredCompany_approve_status_dropdown']")
                                .attr('disabled', true);
                        $("input[name='approve_status']")
                                .attr("readonly", true);
                        $(
                                "input[name='control_registeredCompany_platform_approve_status_dropdown']")
                                .attr('disabled', true);
                        $("textarea[name='approve_result']")
                                .attr("readonly", true);
                        if ($(
                                        "input[name='platform_approve_status']")
                                    .val() == "0"
                            || $(
                                        "input[name='platform_approve_status']")
                                       .val() == "1") {
                            $("#passBtn").hide();
                            $("#rejectBtn").hide();
                        }
                    });
</script>
<body>
<div style="width: 100%;padding:auto;">
    <div id="formtable"></div>
    <iframe id="uploadFrame" src="/business/uploadMain?type=reg#${reg_company_id}" height=250
            width=98% frameborder="no" border="0" marginwidth="0" marginheight="0"></iframe>
</div>
</body>
</html>
